<%@ page language="java" contentType="text/html; charset=utf-8"
         pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>科室修改页面</title>
    <link href="css/style.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript">
        $(function() {
            $('tbody tr:odd').addClass("trLight");

            $(".select-all").click(function() {
                if ($(this).attr("checked")) {
                    $(".checkBox input[type=checkbox]").each(function() {
                        $(this).attr("checked", true);
                    });
                } else {
                    $(".checkBox input[type=checkbox]").each(function() {
                        $(this).attr("checked", false);
                    });
                }
            });

        })

        function checkName(){
            $("#msg").text("");
            var name = $("#name").val();
            $.ajax({
                url:"<%=basePath%>checkName?name="+name,
                dataType : "json",
                //编码设置
                contentType : "application/json;charset=utf-8",
                success : function(data) {
                    if (data.msg != null) {
                        //  alert(data.msg);--onblur事件不要使用alert
                        $("#msg").append(data.msg);
                        $("#name").val("");
                        $("#name").focus();
                    }
                },
                error:function(){
                    alert("后台服务器出错，请联系系统管理员！");
                }
            })
        }
        function goback(){
            window.location.href = "<%=basePath%>deptListController";
        }
    </script>
    <style type="text/css">
        body {
            background: #FFF
        }
        /*#username{*/
        /*    color: red;*/
        /*}*/
        #msg{
            /*font-size: large;*/
            color:red;
        }
    </style>
</head>
<body>
<form method="post" action="<%=basePath%>deptUpdateController" method="post" name="form1">
    <input type="hidden" id="departid" name="departid" value="${dept.departid }" />
    <div id="contentWrap">
        <!--表格控件 -->
        <div id="widget table-widget">
            <div class="pageTitle">科室修改</div>
            <font color="green" size="14">${success }</font>
            <div class="pageInfo">
                <table>
                    <tr>
                        <td width="20%" align="right">科室名</td>
                        <td width="20%"><input type="text" id="name"
                                               name="name" value="${dept.name }"  onblur="checkName()"/>
                            <label id="msg"></label>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="4" align="center">
                            <c:if test="${'1' ne flag }">
                                <input type="submit"   value="确定" />
                            </c:if>
                            <input type="button"	value="返回" onclick="goback()"/></td>
                    </tr>
                </table>
            </div>
        </div>
    </div>

</form>
</body>
</html>